// Script that searches for the existence of the callback page and 
// notifies Firedrop when it hits the page, signifying it's safe
// to move onto the next authentication step

var firedrop_injection = {
	
	domContentLoaded: function(event) {
		var page = event.originalTarget;

		if (page.location && page.location.href.match(/cobweb\.seas\.gwu\.edu\/~cma27\//)) 
		{
			// commented out for now, no need to actually grab this data, we 
			// already have it
			dump("stuff here ");
			var urlSplit = page.location.href.split("?")[1].split("&");
			dump ("url dump" + urlSplit[1]);
			var rawtoken = urlSplit[1].split("=");
			var token = rawtoken[1];
			
			// sends message to firedrop_overlay that it's safe to proceed
			// to step 3 of authentication
			sendAsyncMessage("firedrop:Code", { access_token: token});
		}
	}
};

// loads the event listener for this function
// need to load this dynamically and call removeEventListener
// so it isn't looking at every single page
addEventListener("DOMContentLoaded", firedrop_injection.domContentLoaded, false);

